const { Ls } = require("dayjs");

class SqlCreate {
  action = "";
  selects = [];
  constructor(tableName) {
    this.tableName = tableName;
  }
  //  from(tableName){
  //    this._from = tableName
  //    return this
  //  }
  select(name) {
    this.action = "select";
    this.selects.push(name);
    return this;
  }
  insert() {
    this.action = "insert";
    return this;
  }
  update() {
    this.action = "update";
    return this;
  }
  addWhere() {}
  toSql() {
    const sqls = [];
    switch (this.action) {
      case "select":
        sqls.push(`select ${this.selects.join(',')}`);
        sqls.push(`from :tableName`)
        break;
      case "insert":
        sqls.push(`insert`);
        break;
      case "update":
        sqls.push(`update`);
        break;
      default:
        break;
    }
    return sqls.join(' ')
  }
}

const query = new SqlCreate("user");
query.insert()
console.log('query',query.toSql())
// query.from('user')
// const knex = require('knex')({
//     client: "mysql2",
// })
// const data ={ss:'ss'}
// const pageSize = 1
// const offset = 1
// const sql = knex("users").select("*").insert(data).limit(pageSize).offset(offset).toSQL();

// console.log('qq',sql.sql)
